package com.ltf.controller.adm;

import com.ltf.entity.Task;
import com.ltf.entity.XJson;
import com.ltf.service.TaskService;
import com.ltf.service.XUserService;
import com.ltf.utils.PackJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//管理员排课
@RestController
@RequestMapping("/api/adm/task")
public class TaskController {
    @Autowired
    TaskService taskService;
    @Autowired
    XUserService xUserService;


    public TaskController() {
    }

    //查询所有该年级的所有课程，
    @GetMapping("/findAll")
    public XJson findAll() {
        List<Task> tasks = taskService.findAll();
        System.out.println(tasks);
        return PackJson.packX(200, "", tasks);
    }

    //添加
    @PostMapping("/add")
    //JSON 格式
    public XJson add(@RequestBody Task task) {
        taskService.add(task);
        List<Task> tasks = taskService.findAll();
        return PackJson.packX(200, "添加成功", tasks);
    }

    //删除
    @GetMapping("/del")
    public XJson del(Integer kid) {
        taskService.del(kid);
        List<Task> tasks = taskService.findAll();
        return PackJson.packX(200, "删除成功", tasks);
    }


}
